FROM dockerproxy.net/library/alpine:3.20
 
ARG KUBECTL_VERSION=v1.29.0
ARG TARGETPLATFORM

# 设置proxy
ENV http_proxy="http://172.20.3.88:1088"
ENV https_proxy="http://172.20.3.88:1088"


# curl -LO https://dl.k8s.io/release/v1.29.0/bin/linux/amd64/kubectl
COPY kubectl /usr/local/bin/kubectl
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
COPY config /root/.kube/config

RUN apk update && apk add \
   bash \
   bash-completion \
   busybox-extras \
   net-tools \
   vim \
   curl \
   wget \
   tcpdump \
   ca-certificates && \
   update-ca-certificates && \
   rm -rf /var/cache/apk/* && \
   echo -e 'source /usr/share/bash-completion/bash_completion\nsource <(kubectl completion bash)' >>~/.bashrc && \
   echo -e 'alias k=kubectl\ncomplete -o default -F __start_kubectl k' >>~/.bashrc && \
   chmod +x /usr/local/bin/entrypoint.sh && \
   chmod +x /usr/local/bin/kubectl

ENV http_proxy=""
ENV https_proxy=""   

WORKDIR /app


ENTRYPOINT ["entrypoint.sh"]



# docker build --tag=tableagent-registry.cn-beijing.cr.aliyuncs.com/wedding/wedding-kubectl:1.29.0 .

# docker push tableagent-registry.cn-beijing.cr.aliyuncs.com/wedding/wedding-kubectl:1.29.0


# // 创建测试容器并将kubeconfig挂载到容器中
# docker run --name kubectl -d -v /root/.kube:/root/.kube kubectl:v1.19.7

# docker run --name kubectl -d tableagent-registry.cn-beijing.cr.aliyuncs.com/wedding/wedding-kubectl:1.29.0
# // 进入容器使用kubectl命令
# docker exec -it kubectl bash
# kubectl get pods


# docker run --rm --name kubectl  tableagent-registry.cn-beijing.cr.aliyuncs.com/wedding/wedding-kubectl:1.29.0 -- kubectl get nodes
